from typing import List


class Solution:
    def minSwaps(self, data: List[int]) -> int:
        num = data.count(1)

        now = data[:num].count(1)

        ans = num - now

        for i in range(num, len(data)):
            if data[i] == 1:
                now += 1
            if data[i - num] == 1:
                now -= 1
            ans = min(ans, num - now)

        return ans


if __name__ == "__main__":
    print(Solution().minSwaps([1, 0, 1, 0, 1]))  # 1
    print(Solution().minSwaps([0, 0, 0, 1, 0]))  # 0
    print(Solution().minSwaps([1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1]))  # 3
